
axios.get("/my/user/userinfo ", {
    // headers: {
    //   Authorization: localStorage.getItem("token"),
    // },
  })
  .then(function (res) {
    console.log(res);
    let { username, user_pic, nickname } = res.data.data;
    console.log(username);
    let name = username || nickname;
    $(".username").text(name);
    if (user_pic) {
      $(".layui-nav-img").attr("css", user_pic).show();
    } else {
        let first = name.substring(0,1).toUpperCase();
        $('.user-avatar').text(first).css('display','inline-block')
    }
  });

// 退出功能
$("#logout").on("click", function () {
  layer.confirm("你确定退出吗?", { icon: 3, title: "提示" }, function (index) {
    //do something
    localStorage.removeItem('token')
    location.href = './login.html'
    layer.close(index);
  });
});
